package com.study.happystudy.mapper;

import com.study.happystudy.po.LastMessage;
import com.study.happystudy.po.Message;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MessageMapper {
    // 1. 私信发送
    int sendPrivateMessage(@Param("senderId") int senderId, @Param("receiverId") int receiverId, @Param("messageContent") String messageContent);

    // 2. 私信撤回(类似删除)
    int revokePrivateMessage(@Param("messageId") int messageId);

    // 3. 根据id返回信息
    Message getMessageById(@Param("messageId") int messageId);//

    // 4. 根据id删除信息
    int deleteMessageById(@Param("messageId") int messageId);

    // 5. 系统信息发送
    int sendSystemMessage(@Param("senderId") int senderId, @Param("receiverId") int receiverId, @Param("messageContent") String messageContent);

    // 6. 课程信息发送
    int sendCourseMessage(@Param("senderId") int senderId, @Param("receiverId") int receiverId, @Param("messageContent") String messageContent);

    // 7. 活动信息发送
    int sendActivityMessage(@Param("senderId") int senderId, @Param("receiverId") int receiverId, @Param("messageContent") String messageContent);

    // 8. 社区信息发送
    int sendCommunityMessage(@Param("senderId") int senderId, @Param("receiverId") int receiverId, @Param("messageContent") String messageContent);

    // 9. 根据关键词查找消息(sender_id,receiver_id = id)
    List<Message> searchMessagesByKeyword(@Param("userId") int userId, @Param("keyword") String keyword);
    List<Message> getMessagesByUserId(@Param("userId") int userId, @Param("messageType") String messageType);
    List<Message> getPrivateMessage(@Param("userId1") int userId1, @Param("userId2") int userId2);
    int getPrivateMessageUnreadCount(@Param("userId1") int userId1, @Param("userId2") int userId2);
    int getSystemMessageUnreadCount(@Param("userId") int userId);
    int getCourseMessageUnreadCount(@Param("userId") int userId);
    int getActivityMessageUnreadCount(@Param("userId") int userId);
    int getCommunityMessageUnreadCount(@Param("userId") int userId);
    int privateReadAll(@Param("userId1") int userId1, @Param("userId2") int userId2);
    int systemReadAll(@Param("userId") int userId);
    int courseReadAll(@Param("userId") int userId);
    int activityReadAll(@Param("userId") int userId);
    int communityReadAll(@Param("userId") int userId);
    LastMessage getLastMessage(@Param("userId1") int userId1, @Param("userId2") int userId2);
    List<Integer> getFriendsId(@Param("uid") int uid);
}
